package xyz.eden.boot.common.web.support.application.base.converter;

import xyz.eden.push.application.executor.base.dto.BaseInfoDTO;
import xyz.eden.push.infrastructure.resource.db.po.BasePO;

import java.util.Objects;

/**
 * BaseServiceConverter
 *
 * @author gavin
 * @version 1.0
 * @descriptor
 * @date 2023/4/25 23:18
 */
public interface BaseServiceConverter<PO, DTO> {

    DTO builderDTO(PO po);

    default <PO extends BasePO, DTO extends BaseInfoDTO> void builderBaseInfo(PO po, DTO dto) {
        if (Objects.nonNull(po) && Objects.nonNull(dto)) {
            dto.setId(po.getId());
            dto.setStatus(po.getStatus());
            dto.setCreateTime(po.getCreateTime());
            dto.setCreateMisCode(po.getCreateMisCode());
            dto.setUpdateTime(po.getUpdateTime());
            dto.setUpdateMisCode(po.getUpdateMisCode());
        }
    }
}
